package com.mioto.ld.module.device.dao;

import com.mioto.ld.module.device.model.*;
import com.mioto.ld.module.device.model.app.AppDeviceListVO;
import com.mioto.ld.module.device.model.app.AppDeviceMainPageAddressVO;
import com.mioto.ld.module.device.model.app.AppDeviceMainPageCounterVO;
import com.mioto.ld.module.device.model.app.AppDeviceMainPageVO;
import com.mioto.ld.module.statistics.StatisticsPO;
import com.mioto.ld.module.statistics.model.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 *
 * @author mioto
 * @date 2024-05-15 16:13:50
 */
@Mapper
public interface DeviceDao{

    /**
     * 根据条件查询列表
     * @param device
     * @return
     */
    List<Device> findList(Device device);

    /**
     * 根据列名和对应的值查询对象
     * @param column
     * @param value
     * @return
     */
    Device findByColumn(@Param("column") String column,@Param("value") Object value);

    /**
     * 新增对象
     * @param device
     * @return
     */
    int insert(Device device);

    /**
     * 新增对象,忽略空值
     * @param device
     * @return
     */
    int insertIgnoreNull(Device device);

    /**
     * 修改对象
     * @param device
     * @return
     */
    int update(Device device);

    /**
     * 修改对象,忽略空值
     * @param device
     * @return
     */
    int updateIgnoreNull(Device device);

    /**
     * 根据列名和对应的值删除对象
     * @param column
     * @param value
     * @return
     */
    int deleteByColumn(@Param("column") String column,@Param("value") Object value);

    /**
     * 根据主键列表批量删除
     * @param ids
     * @return
     */
    int batchDelete(Integer[] ids);

    List<DevicePagerVO> findPager(@Param("device")DeviceSearchDTO device,@Param("userId")Integer userId);

    String[] findSnsByProductId(Integer productId);

    String[] findSnsByDeviceIds(String deviceIds);

    int updateLineDateBySn(@Param("sn")String sn,@Param("onlineDate") Date onlineDate,@Param("offlineDate") Date offlineDate);

    DeviceStatusStatisticVO statusStatistics(@Param("device")DeviceSearchDTO device,@Param("userId")Integer userId);

    String[] findDeviceSns(@Param("device")DeviceSearchDTO device,@Param("userId")Integer userId);
    int findFaultStatus(Integer deviceId);

    DeviceDetailVO findDetail(Integer deviceId);

    DeviceDetailAppVO findDetailToApp(Integer deviceId);

    List<AppDeviceMainPageVO> findAppMainData(@Param("userId")Integer userId, @Param("userType")Integer userType);

    AppDeviceMainPageCounterVO findAppMainDeviceData(@Param("productId")Integer productId, @Param("userId")Integer userId);

    List<AppDeviceMainPageAddressVO> findAppMainDeviceAddressData(@Param("productId")Integer productId, @Param("userId")Integer userId);

    List<AppDeviceListVO> findAppDeviceList(Integer[] deviceIds);

    List<AppDeviceMainPageAddressVO> appUserDevices(Integer userId);

    int updateOwnerUser(@Param("deviceSn")String deviceSn, @Param("userId")Integer userId);

    List<DeviceSaleProductStatisticsVO> saleProductStatistics(DeviceSaleSearchDTO searchDTO);

    List<SaleAreaStatisticsVO> saleAreaStatistics(DeviceSaleSearchDTO searchDTO);

    List<SameCompareStatisticsVO> saleSameCompareStatistics(DeviceSaleSearchDTO searchDTO);

    List<DeviceFaultTypeStatisticsVO> faultTypeStatistics(DeviceFaultSearchDTO searchDTO);

    List<SaleAreaStatisticsVO> faultAreaStatistics(DeviceFaultSearchDTO searchDTO);

    List<SameCompareStatisticsVO> faultSameCompareStatistics(DeviceFaultSearchDTO searchDTO);

    List<DeviceFaultTypeStatisticsVO> appFaultTypeStatistics(AppStatisticSearchDTO searchDTO);

    AppDeviceSaleStatisticsVO mainCounterStatistic(AppStatisticSearchDTO searchDTO);

    List<StatisticsPO> appSaleStatistics(AppStatisticSearchDTO searchDTO);
}